//
//  BaseController.swift
//  MySinaWeiBo
//
//  Created by zhangfuwei on 15/7/29.
//  Copyright © 2015年 zhangfuwei. All rights reserved.
//

import UIKit

class BaseController: UITableViewController,visitorViewDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    var userInf = UserAccount.userLogin()
    var visitorV : visitorView?
    
    override func loadView() {
        // MARK: 用户是否登录 to do
        
        userInf ? super.loadView() : setView()
        
    }
    
    func setView() {
        
        visitorV = visitorView()
        visitorV?.delegate = self
        view = visitorV
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "ClickResign")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "ClickLogin")
    }
    
    ///  执行代理方法
    func willResgin() {
        ClickResign()
    }
    
    func willLogin() {
        ClickLogin()
    }
    
    
    
    ///  登录,注册方法
    func ClickResign() {
        print("注册")
    }
    
    func ClickLogin() {
        
        let nav = UINavigationController(rootViewController: OAuthController())
        //  利用 modal 的形式来弹出 OAUth 控制器
        presentViewController(nav, animated: true, completion: nil)
        print("登录")
        
    }
    
}
